package com.cjkj.system.controller;

import com.cjkj.common.core.web.controller.BaseController;
import com.cjkj.common.core.web.domain.AjaxResult;
import com.cjkj.common.security.utils.SecurityUtils;
import com.cjkj.system.api.domain.THospitalUser;
import com.cjkj.system.domain.vo.WarnSetVo;
import com.cjkj.system.service.ITWarnSettingHospitalService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 预警值设置 控制类
 */
@RestController
@RequestMapping("/set")
public class WarnSettingController extends BaseController {

    @Resource
    private ITWarnSettingHospitalService warnSettingHospitalService;

    /**
     * 获取预警值
     */
    @GetMapping("getWarnValueSet")
    public AjaxResult getWarnValueSet() {
        THospitalUser sysUser = SecurityUtils.getLoginUser().getSysUser();
        return AjaxResult.success(warnSettingHospitalService.getDeptWarnSet(sysUser.getHospitalId(), sysUser.getDeptId()));
    }

    /**
     * 保存预警值
     * @param req 预警值
     */
    @PostMapping("saveWarnValue")
    public AjaxResult saveWarnValue(@Valid @RequestBody WarnSetVo req) {
        THospitalUser sysUser = SecurityUtils.getLoginUser().getSysUser();
        return toAjax(warnSettingHospitalService.saveDeptWarnSet(req, sysUser.getHospitalId(), sysUser.getDeptId()));
    }

}
